package com.shazhu.api.nongjt;

import com.shazhu.common.core.domain.AjaxResult;
import com.shazhu.nongjt.domain.NjtArea;
import com.shazhu.nongjt.service.INjtAreaService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Tag(name = "地区管理")
@RestController
@RequestMapping("/api/area")
public class NjtAreaAPI {
    @Autowired
    private INjtAreaService njtAreaService;
    /**
     * 查询所有根节点
     *
     * @return
     */
    @Operation(summary = "查询所有根节点")
    @GetMapping("/queryListRoot")
    public AjaxResult queryListRoot() {
        List<NjtArea> list = njtAreaService.getByParentCode(null);
        return AjaxResult.success(list);
    }
    /**
     * 根据⽗级编码查询⼦级
     *
     * @param parentCode
     * @return
     */
    @Operation(summary = "根据⽗级编码查询⼦级")
    @GetMapping("/queryChildrenByParentCode")
    public AjaxResult queryChildrenByParentCode(@RequestParam("parentCode") String parentCode) {
        List<NjtArea> list = njtAreaService.getByParentCode(parentCode);
        return AjaxResult.success(list);
    }

}